package com.itheima.stock.config;

import com.google.common.util.concurrent.RateLimiter;
import com.itheima.stock.properties.LimiterProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * ClassName: RateLimiterConfiguration
 * Package: com.itheima.stock.config
 * Description: 控制流量生成
 *
 * @Author Lee
 * @Create 2024/11/1
 */
@Configuration
@SuppressWarnings("all")
public class RateLimiterConfiguration {
    /**
     * 控制流量速度
     *
     * @param properties
     * @return
     */
    @Bean
    public RateLimiter rateLimiter(LimiterProperties properties) {
        return RateLimiter.create(properties.getConcurrentNum());
    }

}
